/**
 * 
 */
package com.rocky.project.action.report;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

import com.rocky.project.model.family.Archive;
import com.rocky.project.model.family.Attachment;
import com.rocky.project.model.family.Family;
import com.rocky.project.model.family.Person;

/**
 * @author chen 报表的所有属性，不用set之类的属性
 */
public class ArchiveVO {

	private String houseHolder;

	private String sex;

	private String birthday;

	private String idCard;

	private String postCode;

	private String personNum;

	private String address;

	private String areaNum;

	private String autoNum;

	private String areaCard;

	private String ownType;

	private String useful;

	private String foundationArea;

	private String constructionArea;
	
	private JRDataSource  attDetailDS;

	private ArrayList<AttachmentVO> attachmentsList=new ArrayList<AttachmentVO>(0);
	
	private String subreport_Path="";

	public ArchiveVO()
	{
		
		///WEB-INF/classes/reports/
	}
	/**
	 * @param ar 从归档的对象初始化出一个打印对象
	 */
	public void initArchive(Archive ar) {
		if (ar != null) {
			this.setAutoNum(ar.getAutonum());
			this.setAreaCard(ar.getAreacard());
			this.setAreaNum(ar.getAreanum());
			this.setFoundationArea(ar.getFoundationArea());
			this.setConstructionArea(ar.getConstructionArea());
			this.setUseful(ar.getUseful());
			this.setOwnType(ar.getOwntype());
			Family fm = ar.getFamily();
			if (fm != null) {
				this.setHouseHolder(fm.getHouseholdername());
				Person per = fm.getHouseholder();
				this.setPostCode(fm.getFamilycode());
				this.setAddress(fm.getAddress());
				if (per != null) {
					this.setIdCard(per.getCardnumber());
					this.setSex(per.getSex());
					Date date = per.getBirthday();
					if (date != null){
						this.setBirthday((new SimpleDateFormat("yyyy-MM-dd")).format(date));
					}
				}
				Set set = fm.getPersons();
				if (set != null) {
					this.setPersonNum(String.valueOf(set.size()));
				} else {
					this.setPersonNum("0");
				}
			}
			this.InitFromSet(ar.getPics());
			this.InitFromSet(ar.getPhotos());
			this.InitFromSet(ar.getArchivePics());
			this.InitFromSet(ar.getFiles());
			attDetailDS=new JRBeanCollectionDataSource(this.attachmentsList);
			
		}
	}
	
	private void InitFromSet(Set tmp) {
		Iterator it;
		Attachment att;
		AttachmentVO attvo;
		if (tmp != null) {
			it = tmp.iterator();
			while (it.hasNext()) {
				att = (Attachment) it.next();
				if (!att.isDeleted()) {
					attvo = new AttachmentVO();
					attvo.initAttachment(att);
					this.attachmentsList.add(attvo);
				}
			}
		}
	}

	public String getHouseHolder() {
		return houseHolder;
	}

	/**
	 * @param houseHolder
	 *            户主姓名
	 */
	public void setHouseHolder(String houseHolder) {
		this.houseHolder = houseHolder;
	}

	public String getSex() {
		return sex;
	}

	/**
	 * @param sex
	 *            性别
	 */
	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getBirthday() {
		return birthday;
	}

	/**
	 * @param birthday
	 *            出生年月
	 */
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getIdCard() {
		return idCard;
	}

	/**
	 * @param idCard
	 *            身份证号
	 */
	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getPostCode() {
		return postCode;
	}

	/**
	 * @param postCode
	 *            邮政编码
	 */
	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	public String getPersonNum() {
		return personNum;
	}

	/**
	 * @param personNum
	 *            家里人口数量
	 */
	public void setPersonNum(String personNum) {
		this.personNum = personNum;
	}

	public String getAddress() {
		return address;
	}

	/**
	 * @param address
	 *            联系地址
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	public String getAreaNum() {
		return areaNum;
	}

	/**
	 * @param areaNum
	 *            地号
	 */
	public void setAreaNum(String areaNum) {
		this.areaNum = areaNum;
	}

	public String getAutoNum() {
		return autoNum;
	}

	/**
	 * @param autoNum
	 *            审批表号
	 */
	public void setAutoNum(String autoNum) {
		this.autoNum = autoNum;
	}

	public String getAreaCard() {
		return areaCard;
	}

	/**
	 * @param areaCard
	 *            土地证号
	 */
	public void setAreaCard(String areaCard) {
		this.areaCard = areaCard;
	}

	public String getOwnType() {
		return ownType;
	}

	/**
	 * @param ownType
	 *            权属性质
	 */
	public void setOwnType(String ownType) {
		this.ownType = ownType;
	}

	public String getUseful() {
		return useful;
	}

	/**
	 * @param useful
	 *            用途
	 */
	public void setUseful(String useful) {
		this.useful = useful;
	}

	public String getFoundationArea() {
		return foundationArea;
	}

	/**
	 * @param foundationArea
	 *            占地面积
	 */
	public void setFoundationArea(String foundationArea) {
		this.foundationArea = foundationArea;
	}

	/**
	 * @return
	 */
	public String getConstructionArea() {
		return constructionArea;
	}

	/**
	 * @param constructionArea
	 *            建筑面积
	 */
	public void setConstructionArea(String constructionArea) {
		this.constructionArea = constructionArea;
	}

	

	

	public ArrayList<AttachmentVO> getAttachmentsList() {
		return attachmentsList;
	}

	public void setAttachmentsList(ArrayList<AttachmentVO> attachmentsList) {
		this.attachmentsList = attachmentsList;
	}

	public String getSubreport_Path() {
		return subreport_Path;
	}

	public void setSubreport_Path(String subreport_Path) {
		this.subreport_Path = subreport_Path;
	}
	public JRDataSource getAttDetailDS() {
		return attDetailDS;
	}
	public void setAttDetailDS(JRDataSource attDetailDS) {
		this.attDetailDS = attDetailDS;
	}

	

	

	

}
